import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueJsx(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
      "@components": fileURLToPath(new URL("./src/components", import.meta.url)),
      "@assets": fileURLToPath(new URL("./src/assets", import.meta.url)),
    }
  },
  server: {
    host: "0.0.0.0",
    port: 8091,
    open: true,
    proxy: {
      "^/api": {
        target: "http://localhost:8096/admin", // 后端服务实际地址
        changeOrigin: true, //开启代理
        ws: true,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
    },
  }
})
